﻿package morn.core.components
{

    public class HBox extends LayoutBox
    {
        public static const NONE:String = "none";
        public static const TOP:String = "top";
        public static const MIDDLE:String = "middle";
        public static const BOTTOM:String = "bottom";

        public function HBox()
        {
            return;
        }// end function

        override protected function changeItems() : void
        {
            var _loc_6:Component = null;
            var _loc_1:Array = [];
            var _loc_2:Number = 0;
            var _loc_3:int = 0;
            var _loc_4:* = numChildren;
            while (_loc_3 < _loc_4)
            {
                
                _loc_6 = getChildAt(_loc_3) as Component;
                if (_loc_6)
                {
                    _loc_1.push(_loc_6);
                    _loc_2 = Math.max(_loc_2, _loc_6.displayHeight);
                }
                _loc_3++;
            }
            _loc_1.sortOn(["x"], Array.NUMERIC);
            var _loc_5:Number = 0;
            for each (_loc_6 in _loc_1)
            {
                
                _loc_6.x = _loc_5;
                _loc_5 = _loc_5 + (_loc_6.displayWidth + _space);
                if (_align == TOP)
                {
                    _loc_6.y = 0;
                    continue;
                }
                if (_align == MIDDLE)
                {
                    _loc_6.y = (_loc_2 - _loc_6.displayHeight) * 0.5;
                    continue;
                }
                if (_align == BOTTOM)
                {
                    _loc_6.y = _loc_2 - _loc_6.displayHeight;
                }
            }
            changeSize();
            return;
        }// end function

    }
}
